package com.app.util;


import org.springframework.http.HttpStatus;
import org.springframework.web.server.ResponseStatusException;

/** 其他功能尚未发现
 * @Description:
 * @Author: Rujh
 * @Date: 2022/10/18 17:17
 */
public class BizException extends ResponseStatusException {
    private static final long serialVersionUID = 1L;
    protected String errorCode;
    protected String errorMsg;

    public BizException() {
        super(HttpStatus.INTERNAL_SERVER_ERROR);
    }

    public BizException(String errorMsg) {
        super(HttpStatus.INTERNAL_SERVER_ERROR);
        this.errorMsg = errorMsg;
    }

    public BizException(HttpStatus httpStatus, String errorMsg) {
        super(httpStatus);
        this.errorCode = this.errorCode;
        this.errorMsg = errorMsg;
    }

    public BizException(ErrorCode errorCode) {
        super(errorCode.getHttpStatus());
        this.errorCode = errorCode.getCode();
        this.errorMsg = errorCode.getMessage();
    }

    public BizException(ErrorCode errorCode, String errorMsg) {
        super(errorCode.getHttpStatus());
        this.errorCode = errorCode.getCode();
        this.errorMsg = errorMsg;
    }

    public BizException(HttpStatus httpStatus, String errorMsg, Throwable cause) {
        super(httpStatus);
        this.errorCode = this.errorCode;
        this.errorMsg = errorMsg;
    }

    public String getErrorCode() {
        return this.errorCode;
    }

    public void setErrorCode(HttpStatus httpStatus) {
        this.errorCode = httpStatus.toString();
    }

    public String getErrorMsg() {
        return this.errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public String getMessage() {
        return this.errorMsg;
    }

    public Throwable fillInStackTrace() {
        return this;
    }
}
